import java.util.concurrent.Semaphore;

/*
 * @author zzr
 * @date: 2025/05/11  20:29
 * @description: Semaphore 信号量使用示例
 */
public class Demo17 {
    public static void main(String[] args) throws InterruptedException {
        Semaphore semaphore = new Semaphore(3);
        semaphore.acquire();
        System.out.println("P 操作 1");
        semaphore.acquire();
        System.out.println("P 操作 2");
        semaphore.acquire();
        System.out.println("P 操作 3");

        Thread.sleep(5000);

        semaphore.release();
        semaphore.acquire();
        System.out.println("P 操作 4(5 s 后打印)");

    }
}
